package com.taoz.mianshiwa.commentservice.model.request;

import cn.hutool.core.bean.BeanUtil;
import com.taoz.mianshiwa.commentservice.model.domain.Comment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommentAddDTO {
    /**
     * 回复的评论id，为0表示不是回复
     */
    private Long replyId;

    /**
     * 题库id
     */
    private Long bankId;

    /**
     * 评论用户id
     */
    private Long userId;

    /**
     * 评论内容详情
     */
    private String detail;

    public boolean checkValidate() {
        return bankId != null && userId != null && detail != null;
    }

    public Comment covertToDomain() {
        Comment comment = new Comment();
        BeanUtil.copyProperties(this, comment);
        return comment;
    }
}
